package com.wanhe.base;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.trello.rxlifecycle2.LifecycleTransformer;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;
import com.wanhe.base.injector.component.BaseApplicationComponent;
import com.wanhe.base.util.AppManager;
import com.wanhe.base.util.ViewUtil;


/**
 * Created by XieZaiWei on 2017/6/14.
 * 基类Activity
 */

public abstract class BaseActivity extends RxAppCompatActivity implements IBaseView{
	@Override
	protected void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initComponent(savedInstanceState);
		AppManager.getAppManager().addActivity(this);
	}

	@Override
	public void showLoading() {
	}

	@Override
	public void hideLoading() {
	}

	@Override
	public void showNetError() {
	}

	protected abstract void initComponent(@Nullable Bundle savedInstanceState);
	protected BaseApplicationComponent getAppComponent(){
		return BaseApplication.getApplicationComponent();
	}

	@Override
	public <T> LifecycleTransformer<T> bindToLife() {
		return this.<T>bindToLifecycle();
	}
	/**
	 * 显示弹窗
	 */
	public void showDialog(){
		ViewUtil.loadingDialog(this);
	}

	/**
	 * 隐藏弹窗
	 */
	public void dismissDialog(){
		ViewUtil.dismissLoadingDialog();
	}

	@Override
	public void finish() {
		super.finish();
	}
}
